<?php
/**
 * Model representing country
 * It uses mapper to store countries data in database table.
 *
 * @author 	Damian Sromek <damianpaq@gmail.com>
 * @version 0.1
 */
class Plus_Model_Country_Country extends Plus_Model_Model_EnableDisable_DbTable_Abstract
{
	/**
	 * Country name.
	 *
	 * @var string
	 */
	protected $_name;

	/**
	 * Creates country model with specified data
	 * 
	 * Country's data is send in $options.
	 *
	 * @param 	array $options
	 * @return 	void
	 */
	public function __construct(array $options = array())
	{
		$options['idName'] = '_id';
		$mapper = Plus_Model_Country_Mapper::factory();
		
		parent::__construct($options, $mapper);

		$this	->addVar('_id', 'id_country', 'Id')
				->addVar('_name', 'name', 'Name')
				->addVar('_isEnabled', 'is_enabled', 'IsEnabled');
	}

	/**
	 * Sets country name
	 *
	 * @param 	string $name
	 * @return 	Plus_Model_Country_Country
	 */
	public function setName($name)
	{
		$name = trim((string)$name);
		if(empty($name)) {
			throw new Exception('Name of country must be given');
		}

		$this->_name = $name;
		return $this;
	}

	/**
	 * Gets country name
	 * 
	 * @return string
	 */
	public function getName()
	{
		return $this->_name;
	}
}